﻿using JiveMessenger.Utilities;
using JiveMessenger.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JiveMessenger.User
{
    public class SpotifyHelper
    {
        public static string GetNowPlayingText()
        {
            string format = VmHelper.Locator.CurrentClient.UserSettings.NowPlayingFormat;
            var status = VmHelper.Locator.CurrentClient.SpotifyApi.Status;
            if (status.error != null)
                return "N/A";
            format = format.Replace("{artist}", status.track.artist_resource.name);
            format = format.Replace("{title}", status.track.track_resource.name);
            format = format.Replace("{album}", status.track.album_resource.name);
            format = format.Replace("{elapsed}", StaticMethods.TimeSpanToFormattedString((int)status.playing_position));
            format = format.Replace("{duration}", StaticMethods.TimeSpanToFormattedString((int)status.track.length));
            format = format.Replace("{status}", status.playing ? "Playing" : "Paused");

            return format;
        }
    }
}
